package com.zkthink.ceres.promotion.enums;

import com.zkthink.exception.BizException;
import lombok.Getter;

/**
 * 优惠方式
 * @author vivi.wong
 * @return
 */
@Getter
public enum PromotionTypeEnum {

    FULL_DISCOUNT(1,"满减"),
    DISCOUNT_COUPON(2, "优惠券");

    private int code;

    private String desc;

    PromotionTypeEnum(int code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public static PromotionTypeEnum getType(Integer promotionType) {
        for (PromotionTypeEnum promotionTypeEnum: values()) {
            if (promotionTypeEnum.getCode() == promotionType.intValue()) {
                return promotionTypeEnum;
            }
        }
        throw new BizException("no support promotionType");
    }
}
